/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package query.parser.tokenizer;

/**
 *
 * @author dzb
 */
public class Token {
	
    public enum TokenType {
        None,
        WhiteSpace,
        Alpha,
        Numeric,
        AlphaNumeric,
        Variable,
        OpenBrace,
        CloseBrace,
        OpenBracket,
        CloseBracket,
        QuotedText,
        BlockedText,
        Operator,
        Symbol,
        InLineComment,
        MultiLineComment
    }

	private String value;
	private TokenType type;

	public Token() {
		type = TokenType.None;
		value = "";
	}

	public Token(String value, TokenType type) {
		this.type = type;
		this.value = value;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public TokenType getType() {
		return this.type;
	}

	public void setType(TokenType type) {
		this.type = type;
	}

	public boolean IsTypeIn(TokenType... tokenTypes ) {
		
		if (tokenTypes == null) return false;

		for (TokenType tt : tokenTypes) {
			if( tt == type) {
				return true;
			}
		}
		
		return false;
    }

	@Override
	public boolean equals(Object obj) {
		
		if (obj == null) return false;

		if (! (obj instanceof Token)) return false;

		return (this.type == ((Token)obj).type)
				&& (this.value.equals(((Token)obj).value));
	}

	@Override
	public int hashCode() {
		return value.hashCode();
	}

	@Override
	public String toString() {
		return String.format("%s (%s)", value, type);
	}
}
